package cn.bone.motan.jingzhouArea.gateway.server;

import cn.bone.motan.common.MoRequest;
import cn.bone.motan.common.MoResponse;
import cn.bone.motan.demo1.api.GatewayApi;
import cn.bone.motan.demo1.api.RemoteApi;
import cn.bone.motan.jingzhouArea.util.SpringFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

/**
 * Created by MD-01 on 2017/3/16.
 * 处理本域server发往gateway的请求
 */
@Service
public class GatewayService implements GatewayApi {

    private Logger logger = LoggerFactory.getLogger("jzq-gateway");
    @Override
    public MoResponse execute(MoRequest request) {

        logger.info("收到来自本域server的消息,转发到其他gateway");
        String sign = request.getTo();
        RemoteApi remoteApi = SpringFactory.getBean(sign, RemoteApi.class);
        return remoteApi.execute(request);
    }
}
